package com.hsogoo.study.autoconfiguration;

import com.hsogoo.study.autoconfiguration.bean.XmlBean;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

/**
 * @Author huangsaigang
 * Created @2019-09-29.
 */
@Configuration
@ImportResource("classpath*:sprig-context.xml")
public class ImportResourceApplication {

    public static void main(String[] args) {

        //非web方式启动
        ConfigurableApplicationContext context = new SpringApplicationBuilder(ImportResourceApplication.class)
                .web(WebApplicationType.NONE)
                .run(args);
        //通过@ImportResource导入
        XmlBean xmlBean = context.getBean("xmlBean", XmlBean.class);
        System.out.println("================通过@ImportResource导入===================================");
        System.out.println(xmlBean);

        //关闭上下文
        context.close();

    }
}
